diff --git a/2016/user.php b/2016/user.php index 6fa5a9d..d7ea790 100644 --- a/2016/user.php +++ b/2016/user.php @@ -1,268 +1,269 @@ . require 'load.php'; $conference = FullConference::factoryFromUID( CURRENT_CONFERENCE_UID ) ->queryRow(); $conference or die_with_404(); $user = User::factoryByUID( $_GET['uid'] ) ->select( [ User::ID, User::UID, User::GRAVATAR, User::NAME, User::SURNAME, User::IMAGE, User::WEBSITE, User::LOVED_LICENSE, User::BIO, ] ) ->select( User::allSocialFields() ) ->queryRow(); $user or die_with_404(); FORCE_PERMALINK && $user->forceUserPermalink(); Header::spawn( null, [ 'title' => $user->getUserFullname(), 'url' => $user->getUserURL(), 'og' => [ 'image' => $user->hasUserImage() ? $user->getUserImage() : null, 'type' => 'profile', 'profile:first_name' => $user->user_name, 'profile:last_name' => $user->user_surname ] ] ); ?> hasPermissionToEditUser() ): ?>

getUserUID()}", __("Modifica") . icon('edit', 'left') ) ?>

user_site ): ?>

user_site, __("Sito personale") . icon('contact_mail', 'right'), null, 'btn waves-effect purple darken-2', 'target="_blank"' ) ?>

factoryUserSkills() ->queryGenerator(); ?> valid() ): ?>

getSkillCode() ) ?>
hasUserLovelicense() ): ?>
getUserLovelicense() ?>

" . $license->getLink() . "" ) ?>

hasUserBio() ): ?>

getUserBioHTML( ['p' => 'flow-text'] ) ?>

whereConference( $conference ) ->whereUser( $user ) ->joinTrackChapterRoom() ->queryGenerator(); ?> valid() ): ?>
getEventURL(), sprintf( "%s", esc_html( $title = $event->getEventTitle() ) ), sprintf( __("Vedi %s"), $title ) ) ?> getChapterName() ) ?> getTrackName() ) ?> getLocationName() ) ?>
getRoomName() ) ?>
%s (il %s)"), $event->getEventStart("H:i"), $event->getEventStart("d/m/Y") ) ?>
getEventHumanStart() ?>

joinLocation() + ->joinChapter() ->whereConferenceNot( $conference ) ->whereUser( $user ) ->orderBy( Event::START, 'DESC' ) ->queryGenerator(); - ?> + ?> valid() ): ?>

getEventTitle() ) ?> getConferenceTitle() ) ?> getLocationName() ) ?>
%s (il %s)"), $event->getEventStart("H:i"), $event->getEventStart("d/m/Y") ) ?>
getEventHumanStart() ?>
isUserSocial() ): ?>

has( User::RSS ) and SocialBox::spawn( $user, "RSS", $user->get( User::RSS ), 'home.png' ); $user->has( User::FACEBOOK ) and SocialBox::spawn( $user, "Facebook", $user->getUserFacebruck(), 'facebook_logo.png' ); $user->has( User::GOOGLE_PLUS ) and SocialBox::spawn( $user, "Google+", $user->getUserGuggolpluz(), 'google.png' ); $user->has( User::TWITTER ) and SocialBox::spawn( $user, "Twitter", $user->getUserTuitt(), 'twitter.png' ); $user->has( User::LINKEDIN ) and SocialBox::spawn( $user, "Linkedin", $user->getUserLinkeddon(), 'linkedin.png' ); $user->has( User::GITHUB ) and SocialBox::spawn( $user, "Github", $user->getUserGithubbo(), 'github.png' ); ?>
. require 'load.php'; $conference = FullConference::factoryFromUID( CURRENT_CONFERENCE_UID ) ->queryRow(); if( !$conference ) { die_with_404(); } $user = User::factoryByUID( $_GET['uid'] ) ->queryRow(); if( !$user ) { die_with_404(); } if( FORCE_PERMALINK ) { $user->forceUserPermalink(); } enqueue_js('jquery'); template( 'header', [ 'conference' => $conference, 'title' => $user->getUserFullname(), 'url' => $user->getUserURL(), 'og' => [ 'image' => $user->getUserImage(), 'type' => 'profile', 'profile:first_name' => $user->user_name, 'profile:last_name' => $user->user_surname ] ] ); ?>

getUserFullName() ) ?>

hasPermissionToEditUser() ): ?>

getUserUID()}", __("Modifica") . icon('edit', 'left') ) ?>

has( User::WEBSITE ) ): ?> <?php
 								echo esc_attr( $user->getUserFullname() )
 							?> has( User::WEBSITE ) ): ?>
user_site ): ?>

user_site, __("Sito personale") . icon('inbox', 'right'), null, 'btn waves-effect purple darken-2', 'target="_blank"' ) ?>

factoryUserSkills() ->queryGenerator(); ?> valid() ): ?>

getSkillCode() ) ?>
hasUserLovelicense() ): ?>
getUserLovelicense() ?>

%s."), $license->getLink() ) ?>

hasUserBio() ): ?>

getUserBioHTML( ['p' => 'flow-text'] ) ?>

whereConference( $conference ) ->whereUser( $user ) ->joinTrackChapterRoom() ->queryGenerator(); ?> valid() ): ?>
getEventURL(), sprintf( "%s", esc_html( $title = $event->getEventTitle() ) ), sprintf( __("Vedi %s"), $title ) ) ?> getChapterName() ) ?> getTrackName() ) ?> getLocationName() ) ?>
getRoomName() ) ?>
%s (il %s)"), $event->getEventStart("H:i"), $event->getEventStart("d/m/Y") ) ?>
getEventHumanStart() ?>

joinConference() ->joinLocation() + ->joinChapter() ->whereUser( $user ) ->whereConferenceNot( $conference ) ->orderBy( Event::START, 'DESC' ) ->queryGenerator(); ?> valid() ): ?>

- +
getEventTitle() ) ?>hasConferenceEventsURL() ) { + + // print the Event permalink + echo HTML::a( + $event->getEventURL(), + esc_html( $event->getEventTitle() ) + ); + } else { + + // just print the Event title + echo esc_html( $event->getEventTitle() ); + } + ?> getConferenceTitle() ) ?> getLocationName() ) ?>
%s (il %s)"), $event->getEventStart("H:i"), $event->getEventStart("d/m/Y") ) ?>
getEventHumanStart() ?>
isUserSocial() ): ?>

has( User::RSS ) and UserSocialBox::spawn( $user, "RSS", $user->get( User::RSS ), 'home.png' ); $user->has( User::FACEBOOK ) and UserSocialBox::spawn( $user, "Facebook", $user->getUserFacebruck(), 'facebook_logo.png' ); $user->has( User::GOOGLE_PLUS ) and UserSocialBox::spawn( $user, "Google+", $user->getUserGuggolpluz(), 'google.png' ); $user->has( User::TWITTER ) and UserSocialBox::spawn( $user, "Twitter", $user->getUserTuitt(), 'twitter.png' ); $user->has( User::LINKEDIN ) and UserSocialBox::spawn( $user, "Linkedin", $user->getUserLinkeddon(), 'linkedin.png' ); $user->has( User::GITHUB ) and UserSocialBox::spawn( $user, "Github", $user->getUserGithubbo(), 'github.png' ); ?>
. trait ConferenceTrait { /** * Get conference ID * * @return int */ public function getConferenceID() { return $this->nonnull( Conference::ID ); } /** * Get conference UID * * @return string */ function getConferenceUID() { return $this->get( Conference::UID ); } /** * Get localized conference title * * @return string */ public function getConferenceTitle() { return __( $this->get( Conference::TITLE ) ); } function getConferenceURL( $base = URL ) { return $base . sprintf( PERMALINK_CONFERENCE, $this->getConferenceUID() ); } + /** + * Check if the Conference has URLs for every Event + * + * @return boolean + */ + public function hasConferenceEventsURL() { + return $this->has( 'conference_events_url' ); + } + function forceConferencePermalink() { $url = $this->getConferenceURL( ROOT ); if( $url !== $_SERVER['REQUEST_URI'] ) { http_redirect( $url ); } } function getConferenceHumanStart() { return HumanTime::diff( $this->getConferenceStart() ); } function getConferenceHumanEnd() { return HumanTime::diff( $this->getConferenceEnd() ); } /** * Get the Conference date start * * @param string $format If specified, return the formatted date * @return DateTime|string */ public function getConferenceStart( $format = null ) { $date = $this->get( 'conference_start' ); if( $format ) { return $date->format( $format ); } return $date; } /** * Get the Conference date end * * @param string $format If specified, return the formatted date */ public function getConferenceEnd( $format = null ) { $date = $this->get( 'conference_end' ); if( $format ) { return $date->format( $format ); } return $date; } /** * Get URL to trop-iCal API for this conference * * @param boolean $absolute Set to true for an absolute URL * @return string */ function getConferenceCalURL( $absolute = false ) { $conf = urlencode( $this->getConferenceUID() ); return site_page( "api/tropical.php?conference=$conf", $absolute ); } /** * Get localized conference description * * @return string */ public function getConferenceDescription() { return nl2br( __( $this->get( Conference::DESCRIPTION ) ) ); } /** * Get localized conference quote * * @return string */ public function getConferenceQuote() { return nl2br( __( $this->get( 'conference_quote' ) ) ); } /** * Get localized conference subtitle * * @return string */ public function getConferenceSubtitle() { return __( $this->get( Conference::SUBTITLE ) ); } /** * Factory a FullEvent by this conference * * @return Query */ public function factoryFullEventByConference() { return FullEvent::factoryByConference( $this->getConferenceID() ); } /** * Get the URL to create an Event in this Conference * * @param boolean $absolute Flag to have an absolute URL * @return string */ public function getURLToCreateEventInConference( $args = [], $absolute = false ) { $args['conference'] = $this->getConferenceUID(); return FullEvent::editURL( $args, $absolute ); } /** * Normalize a Conference object */ protected function normalizeConference() { $this->integers( Conference::ID, Conference::DAYS, Location::ID ); $this->datetimes( Conference::START, Conference::END ); } } /** * A Conference is an event in a certain Location */ class Conference extends Queried { use ConferenceTrait; /** * Database table name */ const T = 'conference'; /** * Conference ID column */ const ID = 'conference_ID'; /** * Conference UID column */ const UID = 'conference_uid'; /** * Conference title column */ const TITLE = 'conference_title'; /** * Subtitle column name */ const SUBTITLE = 'conference_subtitle'; /** * Description column name */ const DESCRIPTION = 'conference_description'; /** * Start column name */ const START = 'conference_start'; /** * End column name */ const END = 'conference_end'; /** * Acronym column name */ const ACRONYM = 'conference_acronym'; /** * Persons URL column name */ const PERSONS_URL = 'conference_persons_url'; /** * Events URL column name */ const EVENTS_URL = 'conference_events_url'; /** * Days column name */ const DAYS = 'conference_days'; /** * Complete ID column name */ const ID_ = self::T . DOT . self::ID; /** * Complete Location ID column name */ const LOCATION_ = self::T . DOT . Location::ID; /** * Maximum UID length * * @override */ const MAXLEN_UID = 32; /** * Constructor */ public function __construct() { $this->normalizeConference(); } } diff --git a/includes/class-QueryEvent.php b/includes/class-QueryEvent.php index bd61c8d..2cada45 100644 --- a/includes/class-QueryEvent.php +++ b/includes/class-QueryEvent.php @@ -1,143 +1,156 @@ . /** * Class able to query a FullEvent. */ class QueryEvent extends Query { + /** + * Univoque Chapter ID column name + * + * @var + */ + protected $CHAPTER_ID = 'event.chapter_ID'; + /** * Constructor */ public function __construct() { parent::__construct(); $this->from( Event::T ); $this->defaultClass( FullEvent::class ); } /** * Limit to a certain User * * @param $user User * @return self */ public function whereUser( $user ) { return $this->joinEventUser() ->whereInt( EventUser::USER_, $user->getUserID() ); } /** * Limit to a specific Conference * * @param $conference Conference * @return self */ public function whereConference( $conference ) { return $this->joinConference() ->whereInt( Event::CONFERENCE_, $conference->getConferenceID() ); } /** * Exclude a specific Conference * * @param $conference Conference * @return self */ public function whereConferenceNot( $conference ) { + $id = $conference->getConferenceID(); return $this->joinConference() - ->where( sprintf( - "%s <> %d", - Event::CONFERENCE_, - $conference->getConferenceID() - ) ); + ->whereInt( Event::CONFERENCE_, $id, '<>' ); } /** * Join Events to their Conference * * You can call it multiple time safely. * * @return self */ public function joinConference() { if( empty( $this->joinedConference ) ) { $this->from( Conference::T ); $this->equals( Conference::ID_, Event::CONFERENCE_ ); $this->joinedConference = true; } return $this; } + /** + * Join a table with the Chapter table + * + * @return self + */ + public function joinChapter() { + return $this->joinOn( 'INNER', 'chapter', 'chapter.chapter_ID' , $this->CHAPTER_ID ); + } + /** * Join Events to their Location (and Conference. asd) * * You can call it multiple time safely. * * @TODO: move this method into QueryConference, and extends QueryEvent * @return self */ public function joinLocation() { $this->joinConference(); if( empty( $this->joinedLocation ) ) { $this->from( Location::T ); $this->equals( Location::ID_, Conference::ID_ ); $this->joinedLocation = true; } return $this; } /** * Join Events to User IDs * * You can call it multiple time safely. * * @return self */ public function joinEventUser() { if( empty( $this->joinedEventUser ) ) { $this->from( EventUser::T ); $this->equals( EventUser::EVENT_, Event::ID_ ); $this->joinedEventUser = true; } return $this; } /** * Join Events and their Track, Chapter and Room (can be NULL). * * You can call it multiple time safely. * * @return self */ public function joinTrackChapterRoom() { if( empty( $this->joinedTrackChapterRoom ) ) { $this->from( Room::T ) ->equals( Room::ID_, Event::ROOM_ ); $this->from( Track::T ) ->equals( Track::ID_, Event::TRACK_ ); $this->from( Chapter::T ) ->equals( Chapter::ID_, Event::CHAPTER_ ); $this->joinedTrackChapterRoom = true; } return $this; } }